www.gusucode.com > RQCMS PHP文章管理系统 v2.3PHP源码程序 > RQCMS PHP文章管理系统 v2.3/rqcms_v2.3/rqcms_v2.3/data/plugins/freevectorbox/freevectorbox.php
<?php /* Plugin Name: 安网freevectorbox Version: 1.0 Description: 该插件可以用以完成各种不同的功能。 Author: RQ204 Author URL: http://www.rqcms.com */ //将tag组合到搜索中去 addAction('search_before_featch','freevectorbox_search_before_featch'); addAction('tag_change_sql','freevectorbox_search_before_featch'); //下载前没有处理aid时的处理 addAction('attachment_before_checkaid','freevectorbox_attachment_before_checkaid'); function freevectorbox_attachment_before_checkaid() { global $contentType,$host,$hostid,$DB,$theme,$search_url,$tag_url,$comment_url,$uid,$login_url,$register_url,$groupid,$host_url,$constant,$profile_url,$logout_url,$admin_url; $url = $_GET['url1']; if (!$url) { message('缺少附件参数', './'); } else { $attachinfo = $DB->fetch_first("select aid,url from ".DB_PREFIX."article where url='$url' and hostid=$hostid"); if (!$attachinfo) { message('附件不存在', '/'); } else { $aid=$attachinfo['aid']; $DB->unbuffered_query("UPDATE ".DB_PREFIX."article SET downs=downs+1 WHERE aid='$aid'"); } } //显示下载页面 $tempView=RQ_DATA.'/themes/'.$theme.'/attachment.php';//风格模板文件 include_once $tempView; //输出前处理,输出ContentType,网址重写,插件处理,网页压缩 header($contentType); $output=ob_get_contents(); ob_end_clean(); doAction('before_output'); if($host['gzipcompress']&& function_exists('ob_gzhandler')) { ob_start('ob_gzhandler'); } else { ob_start(); } echo $output; ob_flush();//输出内容 exit(); } function freevectorbox_search_before_featch() { global $contentType,$host,$hostid,$DB,$theme,$search_url,$tag_url,$comment_url,$uid,$login_url,$register_url,$groupid,$host_url,$constant,$profile_url,$logout_url,$admin_url,$articledb; $page=isset($_GET['url2'])?intval($_GET['url2']):1; $keywords = isset($_POST['keywords'])?$_POST['keywords']:''; if(!$keywords&&isset($_GET['url1'])) $keywords = $_GET['url1']; $searchd=$keywords; $pagenums=1; $allcount=0; $keywords = str_replace("_","\_",$keywords); $keywords = str_replace("%","\%",$keywords); if(preg_match("(AND|\+|&|\s)", $keywords) && !preg_match("(OR|\|)", $keywords)) { $andor = ' AND '; $sqltxtsrch = '1'; $keywords = preg_replace("/( AND |&| )/is", "+", $keywords); } else { $andor = ' OR '; $sqltxtsrch = '0'; $keywords = preg_replace("/( OR |\|)/is", "+", $keywords); } $keywords = str_replace('*', '%', addcslashes($keywords, '%_')); foreach(explode("+", $keywords) AS $text) { $text = trim($text); $searchfield=array('tag','title','excerpt'); if($text) { $sqltxtsrch .= $andor.'('; foreach($searchfield as $sfield) { $sqltxtsrch .= "`$sfield` LIKE '%".str_replace('_', '\_', $text)."%' OR ";//title LIKE '%".$text."%' OR excerpt LIKE '%".$text."%' OR tag LIKE '%".$text."%')" ; } $sqltxtsrch=substr($sqltxtsrch,0,strlen($sqltxtsrch)-4).')'; } } //搜索文章 $sortby = 'dateline'; $orderby = 'desc'; $start=($page-1)*$host['list_shownum']; $allarr=$DB->fetch_first("SELECT count(*) FROM ".DB_PREFIX."article WHERE and hostid=$hostid AND ($sqltxtsrch)"); $allcount=$allarr['count(*)']; $query_sql = "SELECT * FROM ".DB_PREFIX."article WHERE and hostid=$hostid AND ($sqltxtsrch) ORDER BY dateline desc limit $start,{$host['list_shownum']}"; $total = $ids = 0; $query = $DB->query($query_sql); while($article = $DB->fetch_array($query)) { $articledb[]=showArticle($article); } $total=count($articledb); $pagenums=@ceil($allcount/$host['list_shownum']); $multipage=''; $title=$keywords.' page '.$page; doAction('search_before_view'); $tempView=RQ_DATA.'/themes/'.$theme.'/search.php';//风格模板文件 include_once $tempView; //输出前处理,输出ContentType,网址重写,插件处理,网页压缩 header($contentType); $output=ob_get_contents(); ob_end_clean(); $output=adminRewrite($output); doAction('before_output'); if($host['gzipcompress']&& function_exists('ob_gzhandler')) { ob_start('ob_gzhandler'); } else { ob_start(); } echo $output; ob_flush();//输出内容 exit(); }